﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Business;

namespace TimKiemDiaDiem
{
    public partial class LoaiTimKiemCtrl : UserControl
    {
        protected String m_TenDichVu = "TatCa";

        public String TenDichVu
        {
            get { return m_TenDichVu; }
            set { m_TenDichVu = value; }
        }

        private IfrmTimKiem m_frmTimKiem = null;

        public IfrmTimKiem FrmTimKiem
        {
            set { m_frmTimKiem = value; }
            get { return m_frmTimKiem; }
        }

        public LoaiTimKiemCtrl()
        {
            InitializeComponent();
            this.Location = new System.Drawing.Point(3, 3);
            this.Name = "m_LoaiTimKiem";
            this.Size = new System.Drawing.Size(522, 137);
            this.TabIndex = 10;
        }

        public virtual List<DiaDiemDTO>TraCuuDiaDiem()
        {
            return new List<DiaDiemDTO>();
        }

        public virtual bool KiemTraDieuKienTraCuu()
        {
            return true;
        }

        protected virtual void TimKiemCtrl_Load(object sender, EventArgs e)
        {
            if ("TatCa" != m_TenDichVu)
            {
                lblExample.Text = "VD : " + " Dương Bá Trạc";
            }
        }

        private void lblkClearText_MouseClick(object sender, MouseEventArgs e)
        {
            txtTuKhoa.Text = "";
        }

        protected void btnTim_Click(object sender, EventArgs e)
        {
            if (!this.KiemTraDieuKienTraCuu())
            {
                return;
            }
            List<DiaDiemDTO> Ketqua = this.TraCuuDiaDiem();

            this.m_frmTimKiem.HienThiKetQua(Ketqua);
        }

        private void txtTuKhoa_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                if (!this.KiemTraDieuKienTraCuu())
                {
                    return;
                }
                List<DiaDiemDTO> Ketqua = this.TraCuuDiaDiem();

                this.m_frmTimKiem.HienThiKetQua(Ketqua);
            }
        }

        public void TraCuu()
        {
            if (!this.KiemTraDieuKienTraCuu())
            {
                return;
            }
            List<DiaDiemDTO> Ketqua = this.TraCuuDiaDiem();

            this.m_frmTimKiem.HienThiKetQua(Ketqua);
        }

       

       
    }
}
